home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
- #
- # start-gateway
- #
- # Copyright 1988-1996 Silicon Graphics, Inc.
- # All rights reserved.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- # the contents of this file may not be disclosed to third parties, copied or
- # duplicated in any form, in whole or in part, without the prior written
- # permission of Silicon Graphics, Inc.
- #
- # RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- # rights reserved under the Copyright Laws of the United States.
- #
- # $Id: start-gateway,v 1.13 1997/05/01 17:54:37 shotes Exp $
-
- require "/usr/OnRamp/lib/OnRamp.pm";
-
- $ifcmd = "/usr/OnRamp/bin/htnetwork";
- $hostsf = "/etc/hosts";
- $hoststmp = "/etc/hosts.tmp";
-
- sub replace_host_entry {
- local($old_ip) = $_[0];
- local($new_ip) = $_[1];
- local($new_hs) = $_[2];
- local($new_dm) = $_[3];
- open(IN,"< $hostsf");
- open(OUT,"> $hoststmp");
- while(<IN>) {
- if (/^#/) {
- print OUT $_;
- next;
- }
- if (/^$old_ip/) {
- print OUT "# ".$_;
- print OUT "$new_ip\t$new_hs.$new_dm\t$new_hs\n";
- next;
- }
- print OUT $_;
- }
- rename($hoststmp, $hostsf);
- }
-
- #
- # Get information from administrator.
- #
-
- if ($< !=0) {
- print "You need to be Superuser (root) to run this script.\n";
- exit 1;
- }
-
- @ifs = `$ifcmd`;
- ($num, $ifnm, $rest) = split(/:/, $ifs[0]);
- @ifconfs = `/usr/etc/ifconfig $ifnm`;
- for ($i = 0; $i <= $#ifconfs; $i++) {
- @fields = split(/\s+/, $ifconfs[$i]);
- for ($j = 0; $j <= $#fields; $j++) {
- if ($fields[$j] eq "inet") {
- $o_address = $fields[$j+1];
- }
- elsif ($fields[$j] eq "netmask") {
- $o_netmask = $fields[$j+1];
- }
- }
- }
- chop($o_hstname = `/usr/bsd/hostname`);
- if ($o_hstname =~ /^([^\.]*)\./) { $o_hstname = $1; }
- ($name, $dummyb, $dummyc, $dummyd, @dummye) = gethostbyname($o_hstname);
- $name =~ /^\w+\.(.*)$/;
- $o_domainname = $1;
-
- print "\nWelcome to your Silicon Graphics WebFORCE Internet Gateway server!\n";
- print "There are a few simple steps to connect your server to the Internet:\n\n";
- print "First, use this terminal window to configure your server to\n",
- "communicate with your local network by means of an IP connection.\n";
- print "Currently, you are using a serial cable connection to communicate\n",
- "between your server and a terminal device (such as a VT-100 terminal\n",
- "or a PC-compatible, Macintosh, or Indy computer running terminal\n",
- "emulation software), but the serial connection will be replaced.\n\n";
-
- print "After you configure your server using this terminal window, you will\n",
- "configure your server to communicate with the Internet. For this\n",
- "step, you will use a Web browser on your PC-compatible, Macintosh \n",
- "or Indy computer. Your computer will communicate with your server \n",
- "through an Ethernet cable.\n";
-
- print "\nThe current configuration of your server is:\n\n";
- print "Hostname: $o_hstname\n";
- print "Domain name: $o_domainname\n";
- print "IP Address: $o_address\n";
- print "Netmask: $o_netmask\n\n";
-
- print "You must change these factory settings to connect your server to the\n",
- "Internet. Most of the information that you need to make these changes\n",
- "is supplied by your Internet service provider (ISP). Make sure you\n",
- "have the appropriate information from your ISP, and follow the\n",
- "steps below.\n";
-
- do {
- do {
- print "\nA hostname uniquely identifies your Silicon Graphics Internet\n",
- "Gateway server. By convention, hostnames contain only lowercase\n",
- "letters.\n\n";
-
- print "Enter a hostname for this server: [$o_hstname] ";
- chomp($hstname = <STDIN>);
- if ($hstname eq "") {
- $hstname = $o_hstname;
- }
- $hstname =~ s/\..*//;
- if (($hstname ne $o_hstname) && check_hostname($hstname)) {
- print "Invalid Hostname '$hstname', Please consult the\n";
- print "administrator's manual for correct Hostname syntax.\n";
- $hstname = "";
- }
- if ($hstname ne "") {
- do {
- print "\nEach organization on the Internet is known by its domain name.\n",
- "Domain names usually contain two (or three) segments, separated by\n",
- "periods. Your ISP assigns domain names. (Example: aspen.com)\n\n";
- print "Enter the Domainname for this server: [$o_domainname] ";
- chomp($dmname = <STDIN>);
- if ( ($o_domainname eq "") && $dmname && check_hostname($dmname)) {
- print "Invalid Domainname '$dmname', Please consult the\n";
- print "administrator's manual for correct Domainname syntax.\n";
- $dmname = "";
- }
- } until ($dmname || $o_domainname);
- if ($dmname eq "") {
- $dmname = $o_domainname;
- }
- }
- } until ($hstname);
-
- do {
- print "\nThe primary network interface connects the server to your local\n",
- "area network. Use an IP address that you obtained from your ISP as\n",
- "the IP address for the primary network interface. (Example: 196.45.23.4)\n\n";
- print "Enter the IP Address of the primary network interface: [$o_address] ";
- chomp($address = <STDIN>);
- if ($address eq "") {
- $address = $o_address;
- }
- if ((address ne $o_address) && check_ipaddr($address)) {
- print "Invalid IP Address '$address', Please consult your\n";
- print "Network administrator for the correct IP Address.\n";
- $address = "";
- }
- } until ( ($address) && ($address ne "192.0.2.1") );
-
- print "\nThe netmask is used in conjunction with the IP address. In most\n",
- "cases, you can use the default netmask.\n\n";
- print "Enter netmask for this interface: [$o_netmask] ";
- chomp($netmask = <STDIN>);
- if ($netmask eq "") {
- $netmask = $o_netmask;
- }
-
- # Verify Netmask
-
- print "\n\nVerify Configuration. You have entered:\n";
- print "Hostname: $hstname\n";
- print "Domainname: $dmname\n";
- print "IP Address: $address\n";
- if ($netmask) {
- print "Netmask: $netmask\n";
- } else {
- print "Netmask is default\n";
- }
-
- print "\nIs this correct? [y/n]: ";
- $answer = <>;
- } until ($answer =~ /^y/i);
-
- #
- # Update /etc/sys_id with new hostname.
- #
- if ($hstname ne $o_hstname) {
- open(SYSID, ">/etc/sys_id") || die "Failed to open /etc/sys_id.\n";
- print SYSID "$hstname\n";
- close(SYSID);
- }
-
- #
- # Update /etc/hosts.
- #
- if (($hstname ne $o_hstname) || ($address ne $o_address)) {
- replace_host_entry($o_address, $address, $hstname, $dmname);
- }
-
- #
- # Update ifconfig-1.options if netmask was specified.
- #
- if ($netmask ne $o_netmask) {
- open(CFG, ">/etc/config/ifconfig-1.options") ||
- die "Failed to write ifconfig-1.options file.\n";
- print CFG "netmask $netmask";
- close(CFG);
- }
-
- `/etc/chkconfig network on`;
-
- print "You now need to reboot your server to put your changes in effect.\n",
- "After your server reboots, complete these steps:\n",
- "\t1. Open a Web browser on your computer\n",
- "\t2. Open the URL \"http://$address:2077/\" in the browser\n",
- "\t3. Select \"Setup Tasks\" on the WebFORCE Internet Gateway Web page\n",
- "\t to continue connecting to the internet.\n";
-
- print "After your server reboots, you can close this terminal window on your\n",
- "terminal (or personal computer) window.\n\n";
-
- print "Reboot server now ? [y|n]";
- $answer = <>;
- if ($answer =~ /^y/i) {
- system ("/etc/init 6");
- }
- exit 0;
-